﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TrainingsApp.Model;
using TrainingsApp.IPADApp.UserControls.Main;

namespace TrainingsApp.IPADApp.UserControls2 {
    public partial class UC_Register : ControlBase {
        protected void Page_Load(object sender, EventArgs e) {
            TS_User_Entity entity = null;
            if (!TemplateUserInfoManager.TryGet(out entity)) {
                Response.Redirect("/PreRegister.aspx");
            }
        }


        protected void btnSubmit_Click(object sender, EventArgs args) {

            string userName = this.txtUserName.Text;
            TS_User_Entity entity = null;
            TemplateUserInfoManager.TryGet(out entity);
            entity.UserName = userName;
            entity.Password = this.txtPassword.Text;
            entity.UserType = ZJFramework10.Utility.FormManager.GetValue<int>("userType", 1);
            entity.Mobile = this.txtMobile.Text;
            entity.Email = this.txtEmail.Text;
            entity.Gender = ZJFramework10.Utility.FormManager.GetValue<int>("gender", 1) == 1 ? true : false;

            TemplateUserInfoManager.Push(entity);

            if (entity.UserType == (int)UserType.Children) {
                Response.Redirect(this.CurPage.RouteHelper.Redirct("/student/RegisterDetail.aspx"));
            }
            else {
                Response.Redirect(this.CurPage.RouteHelper.Redirct("/teacher/RegisterDetail.aspx"));
            }
        }
    }
}